<route lang="json5">
{
  needLogin: true,
  style: {
    navigationStyle: 'default',
    navigationBarTitleText: '考试分析',
  },
}
</route>
<script lang="ts" setup>
import Details from './details.vue'
import Analyse from './analyse.vue'
import Statistics from './statistics.vue'

// 标签页相关
const activeTab = ref(0)

const id = ref()

const tabs = ['考试详情', '考试分析', '统计分析']

onLoad(() => {
  try {
    const pages = getCurrentPages()
    const currentPage = pages[pages.length - 1]
    id.value = currentPage.$page?.options?.id
    console.info('--------------->' + id.value)
  } catch (error) {
    uni.showToast({
      title: '获取课程详情失败',
      icon: 'none',
    })
  }
})
</script>

<template>
  <view class="main_container">
    <!-- 导航栏 -->
    <wd-tabs v-model="activeTab">
      <wd-tab v-for="(tab, index) in tabs" :key="index" :title="tab" />
    </wd-tabs>
    <!-- 内容页 -->
    <view>
      <template v-if="activeTab === 0">
        <Details :id="id"></Details>
      </template>

      <template v-if="activeTab === 1">
        <Analyse :id="id"></Analyse>
      </template>

      <template v-if="activeTab === 2">
        <Statistics :id="id"></Statistics>
      </template>
    </view>
  </view>
</template>

<style scoped>
.main_container {
  display: flex;
  flex-direction: column;
  /* 子view居中显示 */
  background: #f5f5f5;
}
</style>
